package com.example.systemserver.config;

import com.example.systemserver.bean.ResultBean;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@Slf4j
@RestControllerAdvice
public class GlobalExceptionAdvice {

    @ExceptionHandler(MyException.class)
    public ResultBean handleException(MyException e) {
        log.info("全局异常处理,异常信息:{}",e.getMessage());
        return new ResultBean(500, e.getMessage(),null);
    }

    @ExceptionHandler(Exception.class)
    public ResultBean handleException(Exception e) {
        log.info("全局异常处理,异常信息:{}",e.getMessage());
        return new ResultBean(500, "您的网络有问题，请稍后重试",null);
    }

}
